#include "DKInclude.h"

DKPoint::DKPoint(int xIndex, int yIndex)
{
	this->XIndex = xIndex;
	this->YIndex = yIndex;
};

DKEventDirection DKPoint::GetDirection(DKPoint target)
{
		if(this->XIndex == target.XIndex)
		{
			if(this->YIndex > target.YIndex) return DKEventDirection_Down;
			else return DKEventDirection_Up;
		}
		else
		{
			if(this->XIndex > target.XIndex) return DKEventDirection_Left;
			else return DKEventDirection_Right;
		}
}

DKPoint DKPoint::MoveToDirection(DKEventDirection direction)
{
	DKPoint result = DKPoint(this->XIndex, this->YIndex);
	switch(direction)
	{
		case DKEventDirection_Down:
			result.YIndex--;
			break;

		case DKEventDirection_Up:
			result.YIndex++;
			break;

		case DKEventDirection_Left:
			result.XIndex--;
			break;

		case DKEventDirection_Right:
			result.XIndex++;
			break;
	}
	return result;
}

bool DKPoint::IsAlign(DKPoint point)
{
	return point.XIndex == this->XIndex || point.YIndex == this->YIndex;
}

bool DKPoint::IsEqual(DKPoint point)
{
	return point.XIndex == this->XIndex && point.YIndex == this->YIndex;
}